const dateTime = function(data = new Date(), num) {
  // 获取当前日期时间
  const year = data.getFullYear()
  let month = data.getMonth() + 1
  let day = data.getDate()
  let time = data.getHours()
  let minutes = data.getMinutes()
  let seconds = data.getSeconds()
  day = day > 9 ? day : '0' + day
  month = month > 9 ? month : '0' + month
  time = time > 9 ? time : '0' + time
  minutes = minutes > 9 ? minutes : '0' + minutes
  seconds = seconds > 9 ? seconds : '0' + seconds
  return year + '-' + month + '-' + day + ' ' + time + ':' + minutes + ':' + seconds
}
const date = function(number = 0) {
  // 获取当前日期
  const data = new Date(new Date().getTime() + number * 24 * 60 * 60 * 1000)
  const year = data.getFullYear()
  let month = data.getMonth() + 1
  let day = data.getDate()
  day = day > 9 ? day : '0' + day
  month = month > 9 ? month : '0' + month
  return year + '-' + month + '-' + day
}

const time = function(data = new Date()) {
  // 获取当前时间
  let time = data.getHours()
  let minutes = data.getMinutes()
  let seconds = data.getSeconds()
  time = time > 9 ? time : '0' + time
  minutes = minutes > 9 ? minutes : '0' + minutes
  seconds = seconds > 9 ? seconds : '0' + seconds
  return time + ':' + minutes + ':' + seconds
}
module.exports = {
  getdatetime: dateTime,
  getdate: date,
  gettime: time
}
